{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Interactive Mismatched Line" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Intro" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is a demonstration of using IPythons `interact` function with some of `skrf`'s network creation methods." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "As of IPython 2.0, the widgets in this notebook won't show up on http://nbviewer.ipython.org. To view the widgets and interact with them, you will need to download this notebook and run it with an IPython Notebook server.\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import YouTubeVideo\n", "\n", "YouTubeVideo('JyYi_1SswXs',width=700, height=580)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "from ipywidgets import interact\n", "\n", "%matplotlib inline\n", "\n", "import skrf as rf\n", "from skrf import Frequency\n", "from skrf.media import DistributedCircuit\n", "\n", "rf.stylely()\n", "\n", "\n", "# define a frequency object\n", "freq = Frequency(0,10,1001,'GHz')\n", "\n", "# create a Media object for RG-58, based on distributed ckt values\n", "rg58 = DistributedCircuit(frequency = freq,\n", " C =93.5e-12,#F/m\n", " L =273e-9, #H/m\n", " R =0,#53e-3, #Ohm/m\n", " G =0, #S/m\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Mismatched Line" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This demonstrates the response of a mismatched transmission line of a given length. Specifically, a line of electrical length $d$ with characteristic impedance $z_0$ is embedded in the coaxial environment (RG-58 ) with $z_0 \\approx 54 \\Omega$. The resultant S-parameters are plotted in log mag and on the smith chart. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Log Mag" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def func(d=180,z0=54):\n", " ntwk =rg58.line(d=d,unit='deg',z0=z0)\n", " ntwk.renormalize(rg58.z0)\n", " ntwk.plot_s_db(1,0)\n", " ntwk.plot_s_db(0,0)\n", " plt.ylim(-50,20)\n", " plt.draw()\n", " plt.show()\n", "\n", "interact(func, d= (0,360,10),z0=(10,200,1),embed=True);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Smith Chart" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "def func(d=180,z0=54):\n", " ntwk =rg58.line(d=d,unit='deg',z0=z0)\n", " ntwk.renormalize(rg58.z0)\n", " ntwk.plot_s_smith(1,0)\n", " ntwk.plot_s_smith(0,0)\n", " plt.draw()\n", " plt.show()\n", "\n", "\n", "interact(func, d= (0,180,10),z0=(10,200,1),embed=True);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 1 }